#include "selection_sort.h"

namespace algo
{

void selection_sort(vector<int> &vctNums)
{
    if (vctNums.size() <= 1)
    {
        return ;
    }

    for (int i = 0; i < vctNums.size()-1; ++i)
    {
        int iMin = vctNums[i];
        int iMinIndex = i;
        for (int j = i+1; j < vctNums.size(); ++j)
        {
            if (iMin > vctNums[j])
            {
                iMin = vctNums[j];
                iMinIndex = j;
            }
        }
        swap(vctNums[i], vctNums[iMinIndex]);
    }
}

}
